package co.yixiang.yshop.module.product.enums.coupon;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * @author moxiangrong
 * 优惠券过期类型枚举
 */
@Getter
@AllArgsConstructor
public enum CouponExpirationEnum {
    BY_TIME(1, "按时间"),
    BY_DAY(2, "按天数"),
    BY_PERMANENT(3, "无时间限制");

    private Integer value;
    private String desc;
    public static CouponExpirationEnum toType(int type) {
        return Stream.of(CouponExpirationEnum.values())
                .filter(p -> p.value.equals(type))
                .findAny()
                .orElse(null);
    }
}
